package test00.lx05.test03;


import java.util.function.Consumer;

/**
 * @author CSY
 * @date 2025 - 04 - 07
 */
public class MainTest {
    public static void main(String[] args) {
        Student[] stus = {
                new Student("张三",18),
                new Student("李四",16),
                new Student("ZJL",21),
                new Student("赵六",20),
                new Student("哦哈呦",14),
        };
        Consumer<Student[]> consumer1 = (students) -> {
            System.out.println("姓李的学生有：");
            for (Student s : students) {
                if (s.getName().charAt(0) == '李'){
                    System.out.println(s);
                }
            }
        };
        Consumer<Student[]> consumer2 = (students) -> {
            System.out.println("名字有三个字的学生有：");
            for (Student s : students) {
                if (s.getName().length() == 3){
                    System.out.println(s);
                }
            }
        };
        Consumer<Student[]> consumer3 = (students) -> {
            System.out.println("年林大于18岁的学生有：");
            for (Student s : students) {
                if (s.getAge() > 18){
                    System.out.println(s);
                }
            }
        };

        consumer1.andThen(consumer2.andThen(consumer3)).accept(stus);
    }
}
